{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gs_quant.instrument import IRFixedLeg, IRFloatLeg, IRSwap\n",
    "from gs_quant.markets import PricingContext\n",
    "from gs_quant.session import Environment, GsSession"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# external users should substitute their client id and secret; please skip this step if using internal jupyterhub\n",
    "GsSession.use(client_id=None, client_secret=None, scopes=('run_analytics',)) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fixed_leg = IRFixedLeg('Buy', \n",
    "                       fixed_rate=0.05, \n",
    "                       notional_currency='USD', \n",
    "                       termination_date='5y', \n",
    "                       notional_amount=100e6)\n",
    "\n",
    "float_leg = IRFloatLeg('Sell', \n",
    "                       notional_currency='USD', \n",
    "                       termination_date='5y', \n",
    "                       floating_rate_spread=40/1e4, \n",
    "                       notional_amount=100e6)\n",
    "\n",
    "swap = IRSwap(pay_or_receive='Receive', \n",
    "              termination_date='5y', \n",
    "              notional_currency='USD', \n",
    "              fixed_rate=0.05, \n",
    "              floating_rate_spread=40/1e4, \n",
    "              principal_exchange='None', \n",
    "              notional_amount=100e6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "with PricingContext(csa_term='USD-SOFR'):\n",
    "    fixed_price = fixed_leg.price()\n",
    "    float_price = float_leg.price()\n",
    "    swap_price = swap.price()\n",
    "    \n",
    "print(fixed_price.result() + float_price.result())\n",
    "print(swap_price.result())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
